:- [aleph].
:- aleph_open('./resultados.txt',write, Stream), set_output(Stream), flush_output(Stream), set_output(user_output). % Cabecera



%  Ruta de archivo /  nombre de archivo, Número de inducciones     /    Tipo de inducción    /   Número de FOLD
/*
runn('carcinogenesis/extended_aleph/train1',5,'extended_aleph',1),
runn('carcinogenesis/extended_aleph/train2',5,'extended_aleph',2),
runn('carcinogenesis/extended_aleph/train3',5,'extended_aleph',3),	
runn('carcinogenesis/extended_aleph/train4',5,'extended_aleph',4),
runn('carcinogenesis/extended_aleph/train5',5,'extended_aleph',5), 
runn('carcinogenesis/extended_aleph/train6',5,'extended_aleph',6),
runn('carcinogenesis/extended_aleph/train7',5,'extended_aleph',7),
runn('carcinogenesis/extended_aleph/train8',5,'extended_aleph',8),
runn('carcinogenesis/extended_aleph/train9',5,'extended_aleph',9),
runn('carcinogenesis/extended_aleph/train10',5,'extended_aleph',10).
*/
		
runn(_,0,_).
runn(File,Number, Fold):-
        write(Number),
        read_all(File),  induce,   print_performance_theory(Fold),  clean_all,
		N2 is Number-1, 
		runn(File,N2,Fold),!.
		
		

runn(File, Number, AlgorithmType, Fold):-
        aleph_open('./resultados.txt',append, Stream), set_output(Stream),nl,nl,write('Aleph + '),write(AlgorithmType),nl,
        write('Fold, Training Accuracy, Test Accuracy, Time , Number of Rules'),nl,flush_output(Stream),
	    set_output(user_output),
		runn(File, Number,Fold).


print_performance_theory(Fold):-
	   aleph_open('./resultados.txt',append, Stream), set_output(Stream),
       '$aleph_global'(training_accuracy, training_accuracy(TrainingAccuracy)),
       '$aleph_global'(test_accuracy, test_accuracy(TestAccuracy)),
       '$aleph_global'(time_taken, time_taken(TimeTaken)),
       '$aleph_global'(number_of_rules, number_of_rules(NumberOfRules)),
       write(Fold),write(', '),
	   write(TrainingAccuracy),write(',  '),
       write(TestAccuracy),write(',  '),
       write(TimeTaken),write(',  '),
       write(NumberOfRules),nl,
       flush_output(Stream),
	   set_output(user_output).
	   
	   
	   
	   











